# coding: utf-8
from marshmallow import fields
from marshmallow.validate import Range

from app import ma
from app.api.utils import EmptyStrValidator


class FeedbackSchema(ma.Schema):
    """
    create by ld_wu 2017-09-12
    信息反馈
    """
    feedback = fields.Integer()
    # 反馈类型
    feedback_type = fields.Integer()

    feedback_content = fields.Str()

feedback_schema = FeedbackSchema()


class DemandFinishImgSchema(ma.Schema):
    """
    create by ld_wu 2017-11-22
    """
    img = fields.Str(
        required=True,
        error_messages={'required': 'img为必填'},
        validate=EmptyStrValidator(error='img不合法')
    )

demand_finish_img_schema = DemandFinishImgSchema()


class DemandBidSchema(ma.Schema):
    """
    create by ld_wu 2017-11-23
    项目竞标
    """
    offer = fields.Integer(
        required=True,
        error_messages={'required': '出价汇币为必填'},
        validate=[Range(0, error='出价汇币不能小于0')]
    )

demand_bid_schema = DemandBidSchema()
